//
//  ErrorHistoryView.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/16.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "ErrorHistoryView.h"
#import "ErrorHistoryTableCell.h"
#import "ErrorHistoryModel.h"
@implementation ErrorHistoryView
- (void)initView{
    [super initView];
   [self setShowNoDataNotice:@"没有历史任务"];
    self.backgroundColor =[UIColor clearColor];
    self.separatorStyle=UITableViewCellSeparatorStyleNone;
    self.showsVerticalScrollIndicator =NO;
    [self registerCell:[ErrorHistoryTableCell class] withModel:[ErrorHistoryModel class]];
    [self setDataWithUrl:@"warninglist_orderList" andParam:@{@"pageType":@3}];
    [self setTableActionType:CTableActionType_Both];
    [self loadData];
}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (self.scrollView) {
        self.scrollView(scrollView.contentOffset.y);
        return;
    }
    
}

- (void)loadData{
    [super loadData];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.mainData.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 145;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view =[[UIView alloc]init];
    view.backgroundColor =[UIColor clearColor];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section ==0) {
        return 20;
    }else
    {
        return 15;
        
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID = [NSString stringWithFormat:@"Cell_%@", NSStringFromClass([ErrorHistoryModel class])];
    ErrorHistoryTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ErrorHistoryTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.contentView.backgroundColor =[UIColor clearColor];
    
    
    ErrorHistoryModel *model = [self.mainData objectAtIndex:indexPath.section];
    [cell setModel:model];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (self.CCellSelect) {
        if (self.mainData.count == 0) {
            self.CCellSelect(nil);
            return;
        }
        self.CCellSelect([tableView numberOfSections] > 1 || self.needSection ? self.mainData[indexPath.section] : self.mainData[indexPath.section]);
    }
}



@end
